function graph = genGraph(type,num_nodes, num_edges_or_disp_flag,disp_flag)
    graph = 0;
    if nargin < 2 || nargin > 4
            disp('Use:')
            disp('genGraph(t,n,e)')
            disp('  t is a type of graph:')
            disp('    type = 1 ->  complete graph')
            disp('    type = 2 ->  undirected graph')
            disp('    type = 3 ->  directed graph')
            disp('  n is a number of nodes')
            disp('  e is a number of edges (not required for complete graphs)')
    else
        if num_nodes == 1
            disp('Of course, graph which consist from only one node is exists, but please, select higher number of nodes.')
            return
        end
        graph = rand(num_nodes);
        graph = remove_diagonal(graph);
        if nargin == 2 && type == 1
            graph=tril(graph);
            graph = sparse(graph);
        elseif nargin == 3 && type == 1
            graph=tril(graph);
            graph = sparse(graph);
            disp_flag = num_edges_or_disp_flag;
            if disp_flag
                disp_graph(graph,type);
            end
        elseif nargin == 3 && (type == 2 || type == 3)
            num_edges = num_edges_or_disp_flag;
            if (num_edges < num_nodes - 1)
                disp('Please, a number of edges have to be higher or equal than number of nodes - 1.')
                clear graph
                return
            end
            if type == 2
                graph=tril(graph);
            end
            graph = reduce_edges_in_graph(graph,num_edges);
            graph = sparse(graph);
        elseif nargin == 4 && (type == 2 || type == 3)
            num_edges = num_edges_or_disp_flag;
            if (num_edges < num_nodes - 1)
                disp('Please, a number of edges have to be higher or equal than number of nodes - 1.')
                return
            else
                if type == 2
                    graph=tril(graph);
                end
                graph = reduce_edges_in_graph(graph,num_edges);
                graph = sparse(graph);
                if disp_flag
                    disp_graph(graph,type);
                end
            end
        else
            disp('Use:')
            disp('genGraph(t,n,e)')
            disp('  t is a type of graph:')
            disp('    type = 1 ->  complete graph')
            disp('    type = 2 ->  undirected graph')
            disp('    type = 3 ->  directed graph')
            disp('  n is a number of nodes')
            disp('  e is a number of edges (not required for complete graphs)')
            clear graph
            return
        end
    end
end